'use strict';
const crypto = require('crypto')
module.exports = app => {
    const { STRING, INTEGER, DATE, ENUM } = app.Sequelize;
    // 配置（重要：一定要配置详细，一定要！！！）
    const WxUser = app.model.define('wx_user', {
        id: {
            type: INTEGER(20).UNSIGNED,
            primaryKey: true,
            autoIncrement: true
        },
        nickname: {
            type: STRING(20),
            allowNull: false,
            defaultValue: '',
            comment: '昵称',
        },
        avatar: {
            type: STRING(200),
            allowNull: false,
            defaultValue: '',
            comment: '头像',
        },
        openid: {
            type: STRING(100),
            allowNull: false,
            defaultValue: '',
            comment: '用户唯一标识',
        },
        session_key: {
            type: STRING(100),
            allowNull: false,
            defaultValue: '',
            comment: '微信 session_key',
        },
        token: {
            type: STRING(6000),
            allowNull: false,
            defaultValue: '',
            comment: 'token',
        },
        role: {
            type: ENUM,
            values: ['agent', 'user'],
            allowNull: false,
            defaultValue: 'user',
            comment: '角色  agent代理  user用户'
        },
        withdrawal_price: {
            type: INTEGER(30),
            allowNull: false,
            defaultValue: '0',
            comment: '可提现金额',
        },
        total_price: {
            type: INTEGER(30),
            allowNull: false,
            defaultValue: '0',
            comment: '总收益',
        },
        status: {
            type: ENUM,
            values: ['0', '1',],
            allowNull: false,
            defaultValue: '1',
            comment: '状态 0禁用 1启用 '
        },
        created_at: DATE,
        updated_at: DATE,
    });
    return WxUser;
};